//-----------------------------------------------------------------------
// <copyright company="Microsoft Corporation">
//     Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Microsoft.DevDiv.Wpf.Samples
{
    using System;
    using System.Windows;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Media.Effects;
    using System.Windows.Threading;

    /// <summary>
    /// DrawingContextProxy base implementation that merely wraps a DrawingContext
    /// </summary>
    public class DrawingContextProxy : DrawingContextProxyBase, IDisposable
    {
        public static DrawingContextProxy FromDrawingContext(DrawingContext drawingContext)
        {
            return (drawingContext != null) ? new DrawingContextProxy(drawingContext) : null;
        }

        public DrawingContextProxy(DrawingContext drawingContext)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }

            drawingContext.VerifyAccess();

            this.inner = drawingContext;
        }

        public static implicit operator DrawingContextProxy(DrawingContext drawingContext)
        {
            return FromDrawingContext(drawingContext);
        }

        public override void Close()
        {
            this.inner.Close();
        }

        public override void DrawDrawing(Drawing drawing)
        {
            this.inner.DrawDrawing(drawing);
        }

        public override void DrawEllipse(Brush brush, Pen pen, Point center, AnimationClock centerAnimations, double radiusX, AnimationClock radiusXAnimations, double radiusY, AnimationClock radiusYAnimations)
        {
            this.inner.DrawEllipse(brush, pen, center, centerAnimations, radiusX, radiusXAnimations, radiusY, radiusYAnimations);
        }

        public override void DrawEllipse(Brush brush, Pen pen, Point center, double radiusX, double radiusY)
        {
            this.inner.DrawEllipse(brush, pen, center, radiusX, radiusY);
        }

        public override void DrawGeometry(Brush brush, Pen pen, Geometry geometry)
        {
            this.inner.DrawGeometry(brush, pen, geometry);
        }

        public override void DrawGlyphRun(Brush foregroundBrush, GlyphRun glyphRun)
        {
            this.inner.DrawGlyphRun(foregroundBrush, glyphRun);
        }

        public override void DrawImage(ImageSource imageSource, Rect rectangle, AnimationClock rectangleAnimations)
        {
            this.inner.DrawImage(imageSource, rectangle, rectangleAnimations);
        }

        public override void DrawImage(ImageSource imageSource, Rect rectangle)
        {
            this.inner.DrawImage(imageSource, rectangle);
        }

        public override void DrawLine(Pen pen, Point point0, System.Windows.Media.Animation.AnimationClock point0Animations, Point point1, System.Windows.Media.Animation.AnimationClock point1Animations)
        {
            this.inner.DrawLine(pen, point0, point0Animations, point1, point1Animations);
        }

        public override void DrawLine(Pen pen, Point point0, Point point1)
        {
            this.inner.DrawLine(pen, point0, point1);
        }

        public override void DrawRectangle(Brush brush, Pen pen, Rect rectangle, AnimationClock rectangleAnimations)
        {
            this.inner.DrawRectangle(brush, pen, rectangle, rectangleAnimations);
        }

        public override void DrawRectangle(Brush brush, Pen pen, Rect rectangle)
        {
            this.inner.DrawRectangle(brush, pen, rectangle);
        }

        public override void DrawRoundedRectangle(Brush brush, Pen pen, Rect rectangle, AnimationClock rectangleAnimations, double radiusX, AnimationClock radiusXAnimations, double radiusY, AnimationClock radiusYAnimations)
        {
            this.inner.DrawRoundedRectangle(brush, pen, rectangle, rectangleAnimations, radiusX, radiusXAnimations, radiusY, radiusYAnimations);
        }

        public override void DrawRoundedRectangle(Brush brush, Pen pen, Rect rectangle, double radiusX, double radiusY)
        {
            this.inner.DrawRoundedRectangle(brush, pen, rectangle, radiusX, radiusY);
        }

        public void DrawText(FormattedText formattedText, Point origin)
        {
            this.inner.DrawText(formattedText, origin);
        }

        public override void DrawVideo(MediaPlayer player, Rect rectangle, AnimationClock rectangleAnimations)
        {
            this.inner.DrawVideo(player, rectangle, rectangleAnimations);
        }

        public override void DrawVideo(MediaPlayer player, Rect rectangle)
        {
            this.inner.DrawVideo(player, rectangle);
        }

        public override void Pop()
        {
            this.inner.Pop();
        }

        public override void PushClip(Geometry clipGeometry)
        {
            this.inner.PushClip(clipGeometry);
        }

        public override void PushEffect(BitmapEffect effect, BitmapEffectInput effectInput)
        {
            this.inner.PushEffect(effect, effectInput);
        }

        public override void PushGuidelineSet(GuidelineSet guidelines)
        {
            this.inner.PushGuidelineSet(guidelines);
        }

        public override void PushOpacity(double opacity, AnimationClock opacityAnimations)
        {
            this.inner.PushOpacity(opacity, opacityAnimations);
        }

        public override void PushOpacity(double opacity)
        {
            this.inner.PushOpacity(opacity);
        }

        public override void PushOpacityMask(Brush opacityMask)
        {
            this.inner.PushOpacityMask(opacityMask);
        }

        public override void PushTransform(Transform transform)
        {
            this.inner.PushTransform(transform);
        }

        public Dispatcher Dispatcher
        {
            get { return this.inner.Dispatcher; }
        }

        public bool CheckAccess()
        {
            return this.inner.CheckAccess();
        }

        public void VerifyAccess()
        {
            this.inner.VerifyAccess();
        }

        protected virtual void Dispose(bool isDisposing)
        {
            if (isDisposing)
            {
                ((IDisposable)this.inner).Dispose();
            }
        }

        void IDisposable.Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        private DrawingContext inner;
    }
}